/**
 * Input prompt example
 */

'use strict';
var inquirer = require('inquirer'),
    fs = require('fs');
const repl = require('repl');
var questions = [
    {
        type: 'input',
        name: 'project_name',
        message: 'What\'s your project name'
    },
    {
        type: 'input',
        name: 'install_path',
        message: 'What\'s your project install_path',
        default: function () {
            return __dirname;
        }
    },
    {
        type: 'confirm',
        name: 'isStrict',
        message: 'open strict mode',
        default: function () {
            return true;
        }
    },
    {
        type: 'confirm',
        name: 'isInstall',
        message: 'install the project now',
        default: function () {
            return true;
        }
    }
];

inquirer.prompt(questions).then(function (answers) {
    fs.writeFile('./lib/init.json', JSON.stringify(answers, null, ''), function (err) {
        if (err) throw err;
    fs.readFile('./lib/init.json', function (err, data) {
        if (err)
            throw err;

        var jsonObj = JSON.parse(data);
        var project_name = jsonObj['project_name'];
        var install_path = jsonObj['install_path'];
        var isStrict = jsonObj['isStrict'];
        var isInstall = jsonObj['isInstall'];

        if (isInstall) {
           /* repl.start({
             prompt: __dirname+'npm install -g gulp'
             });*/
            console.log("install");

        }
        else {
            console.log("uninstall");
        }
    });
});
});





